package com.action.message;

import java.util.Map;

import com.db.message.*;
import com.opensymphony.xwork2.ActionContext;

public class DeleteAction {

	private int no[];
	private String sd_rv;
	private MessageDAO msg;

	public MessageDAO getMsg() {
		return msg;
	}

	public void setMsg(MessageDAO msg) {
		this.msg = msg;
	}

	public int[] getNo() {
		return no;
	}

	public void setNo(int[] no) {
		this.no = no;
	}

	public String getSd_rv() {
		return sd_rv;
	}

	public void setSd_rv(String sd_rv) {
		this.sd_rv = sd_rv;
	}

	public String msgDelete() throws Exception {
		String result = "";
		if (no == null) {

		} else {

			for (int i = 0; i < no.length; i++) {

				if (sd_rv.equals("sd")) {

					msg.msgSendDelete(no[i]);
					result = "sd";
				} else {
					msg.msgRecvDelete(no[i]);
					result = "rv";
				}

			}
			msg.msgAllDelete();
		}
		return result;
	}

	public String msgAllDelete() throws Exception {

		Map session = ActionContext.getContext().getSession();
		String id = (String) session.get("login");
		System.out.println(id);
		if (sd_rv.equals("sd")) {

			msg.allSendDelete(id);
		} else {
			msg.allRecvDelete(id);
		}

		msg.msgAllDelete();

		return "success";
	}

}
